package com.softcits.hw.aop;

import org.springframework.stereotype.Component;

import com.softcits.hw.aop.aspect.AdminRole;

@Component("cal")
public class Caculator implements ICaculator {

    @Override
    public double add(double a, double b) {
        System.out.println("add is running...");
        return a + b;
    }

    @Override
    public double minus(double a, double b) {
        return a - b;
    }

    @Override
    @AdminRole
    public double multiply(double a, double b) {
        return a * b;
    }

    @Override
    @AdminRole
    public double divide(double a, double b) {
        if(b == 0) {
            throw new RuntimeException("b can not be zero.");
        }
        return a / b;
    }

}
